package demo2;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component
@PropertySource("classpath:config.properties")
public class Student {
    @Value("${student.name}")
    private String name;
    @Value("${student.age}")
    private int age;

    @Override
    public String toString() {
        return "name="+name+", age="+age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Value("小三")
    public String getName() {
        return name;
    }

    @Value("小八")
    public void setName(String name) {
        this.name = name;
    }

    @Value("18")
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
